package com.cn.jinl.service;

import com.cn.jinl.api.ILoginLogService;
import com.cn.jinl.dao.LoginLogMapper;
import com.cn.jinl.domain.LoginLog;
import com.cn.jinl.utils.CommonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import java.net.Inet4Address;
import java.net.InetAddress;
import java.util.List;

/**
 * @类名:LoginLogServiceImpl
 * @包名:com.cn.jinl.service
 * @作者:chenxingliang
 * @时间:2022-11-13 10:27
 * @版本:1.0.0
 */

@Service
public class LoginLogServiceImpl implements ILoginLogService {

    @Autowired
    private LoginLogMapper loginLogMapper;

    @Autowired
    HttpServletRequest httpServletRequest;

    @Override
    public List<LoginLog> getILoginLogList() throws Exception {
        return null;
    }

    @Override
    public String addLoginLogDetail(LoginLog loginLog) throws Exception {
        InetAddress ip4 = Inet4Address.getLocalHost();
        String ip = ip4.getHostAddress();
        loginLog.setIp(ip);
        loginLog.setId(CommonUtil.generateRandomNum("loginlog-"));
        int count = loginLogMapper.insertSelective(loginLog);
        return CommonUtil.outStr(count);
    }

    @Override
    public String updateLoginLogDetail(LoginLog loginLog) throws Exception {
        return null;
    }

    @Override
    public String delLoginLogDetail(List<LoginLog> loginLogs) throws Exception {
        return null;
    }
}
